<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
test(() => assert_selection(
    '<div contenteditable>|<br></div>',
    selection => {
        selection.document.execCommand('insertHTML', false, [
            '<div>\n',
                '<div>\n',
                    '<input type="text"> \n',
                    '<span>b</span>\n',
                '</div>\n',
            '</div>',
        ].join(''));
    },
    [
        '<div contenteditable>',
            '<div>\n',
                '<div>\n',
                    '<input type="text"> \n',
                    'b|\n',
                '</div>',
            '</div>',
        '</div>',
    ].join('')),
    'insert an text field in nested div');

test(() => assert_selection(
    '<div contenteditable>|<br></div>',
    selection => {
        selection.document.execCommand('insertHTML', false, [
            '<div>\n',
                '<div>\n',
                    '<textarea>a</textarea> \n',
                    '<span>b</span>\n',
                '</div>\n',
            '</div>',
        ].join(''));
    },
    [
        '<div contenteditable>',
            '<div>\n',
                '<div>\n',
                    '<textarea>a</textarea> \n',
                    'b|\n',
                '</div>',
            '</div>',
        '</div>',
    ].join('')),
    'insert a TEXTAREA in nested div');
</script>
